package com.fairytask.engine.components.Scroll
{
	import com.fairytask.engine.components.BaseComponent;
	import com.fairytask.engine.utils.draw.DrawAPI;
	import com.fairytask.engine.utils.draw.DrawStyle;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.geom.Rectangle;
	
	public class ScrollPanelLite extends BaseComponent
	{
		private var scrollSpace	:Sprite;
				
		private var sPanle			:ScrollPanel;
		
		private var sPanleSkin		:ScrollSkin;
		
		private var dWidth			:uint	=	0;
		
		private var dHeight		:uint	=	0;
		
		public function ScrollPanelLite(width:uint,height:uint,_skin:ScrollSkin)
		{
			dWidth		=	width;
			dHeight		=	height;
			sPanleSkin	=	_skin;
			init()
		}
		
		private function init():void
		{
			scrollSpace	=	new Sprite();
			DrawAPI.drawRect(scrollSpace.graphics,
				DrawStyle.getRectStyle(0,0,dWidth,dHeight+16),
				DrawStyle.getFillStyle(0x556B75,0));						
			sPanle	=	new ScrollPanel(new Rectangle(0,0,dWidth,dHeight),scrollSpace,sPanleSkin,true);
			addChild(sPanle);
		}
		
		public function addView(val:DisplayObject):void
		{
			scrollSpace.addChild(val);
			sPanle.update();
		}
		
		public function removeView(val:DisplayObject):void
		{
			if(val.parent == scrollSpace)
			{
				scrollSpace.removeChild(val);
			}
			sPanle.update();
		}
		
		public function remove():void
		{
			sPanle.remove()
		}
		
		public function update():void
		{
			sPanle.update();
		}
		
		public function setDefaultSize(valWidth:uint,valHeight:uint):void
		{			
			sPanle.remove();
			dWidth	=	valWidth;
			dHeight	=	valHeight;
			
			DrawAPI.drawRect(scrollSpace.graphics,
				DrawStyle.getRectStyle(0,0,dWidth,dHeight+16),
				DrawStyle.getFillStyle(0x556B75,0));						
			sPanle	=	new ScrollPanel(new Rectangle(0,0,dWidth,dHeight),scrollSpace,sPanleSkin,true);
			addChild(sPanle);
		}
	}
}